package com.xue.service.impl;

import com.xue.mapper.EmpMapper;
import com.xue.pojo.JobOption;
import com.xue.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;

    /*
     * 获取各个职位的员工数量
     * */
    @Override
    public JobOption empJobData() {
        //1.调用mapper接口获取统计数据
        List<Map<String, Object>> list = empMapper.empJobData();//第一个map集合: pos:'教研主管' num:1 ,一个map里面可以有多个key
        //2.将数据封装到JobOption对象中


        List<Object> pos = list.stream().map(map -> map.get("pos")).toList();
        List<Object> num = list.stream().map(map -> map.get("num")).toList();
        JobOption jobOption = new JobOption(pos, num);

        return jobOption;
    }

    /*
    * 获取员工性别数量
    * */
    @Override
    public List<Map<String, Object>> empGenderData() {
        //1.调用mapper接口获取统计数据
        List<Map<String, Object>> list = empMapper.empGenderData();
        return list;
    }
}
